{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 47 NoSQL数据库"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.请自行下载并安装NoSQL。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：参见本章Memcached的下载与安装方法。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.【选择】在Memcached中，定义一个client用方法（ ），定义多个clients用方法（ ）。  \n",
    "\n",
    "A.Client();Client()  \n",
    "B.Client();HashClient()  \n",
    "C.HashClient();HashClient()  \n",
    "D.HashClient();Client()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：B"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.【填空】请写出以下代码的运行结果。（ ）  \n",
    "`value1=\"data1\"\n",
    "client1 = Client(('localhost', 11211))\n",
    "client1.set('key1', value1)\n",
    "client1.set('key1', \"test1\")\n",
    "client1.get('key1')`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：b'test1'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4.【填空】请写出以下代码的运行结果。（ ）  \n",
    "`value2=\"data2\"\n",
    "client2 = Client(('localhost', 11211))\n",
    "client2.set('key2', value2)\n",
    "client2.add('key2', \"test2\")\n",
    "client2.get('key2')`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：b'data2'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5.【填空】请写出以下代码的运行结果。（ ）  \n",
    "`value3=\"data3\"\n",
    "client3 = Client(('localhost', 11211))\n",
    "client3.set('key3', value3)\n",
    "client3.replace('key3', \"info\")\n",
    "print(\"key3 is \",client3.get(\"key3\"))`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：key3 is b'info'"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
